package utils;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class MD5Coder {
	
	/**
	 * Encode a clear text into an MD5 hash
	 */
	public static String getEncodedText(String text){
		MessageDigest md = null;
		try{
			md = MessageDigest.getInstance("MD5");
			md.update(text.getBytes());
		} catch (NoSuchAlgorithmException e){
			System.err.println(e.getMessage());
		}
		if (md != null){
			return HexString.bufferToHex(md.digest());
		} else {
			return null;
		}
	}
}
